let ul = document.querySelector(".list");
let marginTop = 0;
let id;
//鼠标移出时，开启定时器
ul.addEventListener("mouseleave", function () {
    if (id) {
        clearInterval(id);
    };
    id = setInterval(loop, 20);
}, false);
//鼠标移入时，关闭定时器
ul.addEventListener("mouseenter", function () {
    if (id) {
        clearInterval(id);
    }
}, false);
// 文字向上无限循环
function loop() {
    let li = ul.firstElementChild;
    marginTop--;
    let height = li.offsetHeight
    if (marginTop === -height) {
        ul.appendChild(li);
        marginTop = 0;
    }
    li.style.marginTop = marginTop + "px";
}
if (id) {
    clearInterval(id);
};
id = setInterval(loop, 20);